const a = function (
  { formModel },
  { me, memory },
  { dc: { update, upload }, instance, xe }
) {
  const gridFile = "1778625325733449729";
  return {
    api: async (...args) => {
      const params = args[0];
      if (!params["filename"]) params["filename"] = params.file.name;
      const ret = await upload(...args);
      const FILEPATH = ret?.data?.url;
      const FILENAME = params.file.name;
      const FILESIZE = params.file.size;
      console.log("upload: ", args, update, FILENAME, FILEPATH, FILESIZE);
      const { get, set } = xe;
      const files = get(memory, `${me}.files`, []);
      files.push({ FILENAME, FILEPATH, FILESIZE });
      set(memory, `${me}.files`, files);
      return ret;
    },
    showPreview: false,
    emptyHidePreview: true,
    multiple: true,
    maxNumber: 5,
    helpText: "支持word文档、图片和PDF格式，单个文件不超过2MB",
    accept: [".doc", ".docx", ".pdf", "application/msword", "image/*"],
    centered: true,
    getContainer: () => instance?.proxy?.$el,
    onChange: async (urls) => {
      const { get, set } = xe;
      const files = get(memory, `${me}.files`);
      console.log("form file change: ", urls, files, formModel);
      for (const value of files)
        await update({ path: gridFile, action: "add", index: -1, value });
      set(memory, `${me}.files`, []);
      formModel["files"] = [];
    },
    onDelete: (...args) => {
      console.log("form file delete: ", args, formModel["files"]);
    },
  };
};